/**
 * 
 */
var DASH_BOARD 					= 'dash_board';
var REPAIR_ORDER_CREATE 		= 'repair_order_create';
var REPAIR_ORDER_RETRIEVE 		= 'repair_order_retrieve';
var REPAIR_ORDER_FACTORY 		= 'repair_order_factory';
var REPAIR_ORDER_FACTORY_CERT	= 'repair_order_factory_cert';
var REPAIR_RECORD_LIST			= 'repair_record_list';
			
var menuHashMap = {};
menuHashMap[DASH_BOARD] 				= {text:'대시보드', 		url:contextPath + '/dash_board'};
menuHashMap[REPAIR_ORDER_CREATE] 		= {text:'수리 요청 작성', 	url:contextPath + '/repair_order_create'};
menuHashMap[REPAIR_ORDER_RETRIEVE] 		= {text:'수리 요청 조회', 	url:contextPath + '/repair_order_retrieve/dhtmlx'};
menuHashMap[REPAIR_ORDER_FACTORY] 		= {text:'수리 요청 출고', 	url:''};
menuHashMap[REPAIR_ORDER_FACTORY_CERT] 	= {text:'수리 요청 출고증',	url:''};
menuHashMap[REPAIR_RECORD_LIST] 		= {text:'수리 실적 LIST',	url:contextPath + '/repair_record_list/dhtmlx'};

dhtmlx.image_path = contextPath + "/resources/common/dhtmlx/imgs/";

var mainLayout;
var leftLayout;
var rightLayout;
var mainTabbar;

//var myTabbar = new dhtmlXTabBar("aaa");
//myTabbar.enableTabCloseButton(l)

//var myTree = new dhtmlXTreeObject("aaa", "100%", "100%", 0);
//myTree.loadXML(contectPath + "/resources/xml/menu_tree.xml");


dhtmlxEvent(window, 'load', function() {
	mainLayout = new dhtmlXLayoutObject("contents_div", '2U');
	leftLayout = mainLayout.cells("a");
	rightLayout = mainLayout.cells("b");
	
	leftLayout.setText("메뉴");
	leftLayout.setWidth(200);
	
	mainTree = leftLayout.attachTree();
	mainTree.setIconsPath(contextPath + "/resources/common/dhtmlx/imgs/dhxtree_terrace/", function() {});

	for ( var oneMenu in menuHashMap ) {
		mainTree.insertNewChild(0, oneMenu, menuHashMap[oneMenu]['text']);
	}
	
	mainTree.setOnClickHandler(treeOnclick);
	
	mainTabbar = rightLayout.attachTabbar();
	mainTabbar.enableTabCloseButton(true);
	
	mainTabbar.addTab(DASH_BOARD, menuHashMap[DASH_BOARD]['text'], null, null, true);
	mainTabbar.tabs(DASH_BOARD).attachURL(menuHashMap[DASH_BOARD]['url']);
});

function treeOnclick(id) {
	if ( mainTabbar.tabs(id) != null ) {
		mainTabbar.tabs(id).setActive();
	}
	else {
		//progressOn();
		
		mainTabbar.addTab(id, menuHashMap[id]['text'], null, -1);
		mainTabbar.tabs(id).attachURL(menuHashMap[id]['url']);
		mainTabbar.tabs(id).setActive();
	}
}

function progressOn() {
	rightLayout.progressOn();
}

function progressOff() {
	rightLayout.progressOff();
}